package com.yoomiito.app.base;

import com.yoomiito.app.model.bean.UserInfo;
import com.yoomiito.app.net.YmApi;

import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;

public abstract class BaseLazyFragmentPresenter<T extends BaseLazyFragment> extends BasePresenter<T> {

    public AppConfig mAppConfig;

    public BaseLazyFragmentPresenter(AppConfig appConfig) {
        super(appConfig);
    }

    public void getUserInfo() {
        YmApi.getYmService()
                .getUserInfo()
                .compose(getV().bindToLifecycle())
                .compose(XApi.<UserInfo>getApiTransformerData())
                .compose(XApi.<UserInfo>getScheduler())
                .subscribe(new ApiSubscriber<UserInfo>(handleException()) {
                    @Override
                    public void onSuccess(UserInfo userInfo) {
                        getV().setUserInfo(userInfo);
                    }

                    @Override
                    public void onFail(ApiException error) {

                    }
                });
    }
}

